home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / RGASM.RAR / ASMCODE.EXE / CHAPT10 / PRINBIOS.ASM < prev    next >
Encoding:
Assembly Source File  |  1993-05-10  |  2.8 KB  |  62 lines

  1. ;****************************************************************
  2. ;  Program PrinBios ( Chapter 10 )
  3. ;
  4. ;  The program for outputting text string onto the printer
  5. ;
  6. ;  Author: A.I.Sopin, Voronezh, Russia,  1991
  7. ;
  8. ;  The BIOS service (INT 17h, function 00h) is used
  9. ;
  10. ;****************************************************************
  11. .MODEL  SMALL
  12. .STACK
  13. .DATA
  14. ;----------------------------------------------------------
  15. CR       EQU    13    ;  Carriage Return
  16. LF       EQU    10    ;  Line Feed
  17. MSG1     DB     ' Output a string onto the printer (BIOS, INT 17h) '
  18.      DB     CR, LF
  19. LMSG1    EQU    $-MSG1
  20. MSG2     DB     13,10, 'Error while outputting the string !!!',13,10,'$'
  21. MSG3     DB     13,10, 'Printer not ready !!!',13,10,'$'
  22. MSG4     DB     13,10, 'Error during printer initialisation !!!',13,10,'$'
  23. ;----------------------------------------------------------
  24. .CODE
  25. .startup
  26.      mov    ah,2            ;  function 03h - get printer status byte
  27.      xor    dx,dx           ;  DX=0 corresponds to LPT1
  28.      int    17h             ;  BIOS printer service 
  29.      cmp    ah,90h          ;  check bits 7 and 4 of status byte
  30.      jz     Init            ;  if printer is OK - initialize it
  31.      lea    dx,MSG3         ;  address of message "not ready"
  32.      jmp    Text            ;  output message and exit
  33. ;--- Initialize the printer
  34. Init:    mov    ah,1            ;  Function 01h - initialize printer
  35.      xor    dx,dx           ;  DX=0 denotes LPT1
  36.      int    17h             ;  BIOS printer service
  37.      cmp    ah,00h          ;  check printer status
  38.      jz     Print           ;
  39.      lea    dx,MSG4         ;  address of message "Printer is not ready"
  40.      jmp    Text            ;  output message and exit
  41. ;----------------------------------------------------------
  42. ;--- Send ASCII-string onto the printer
  43. Print:   mov    cx,LMSG1        ;  length of string into CX
  44.      lea    si,MSG1         ;  DS:SI - address of string
  45.      cld                    ;  direction - forward!
  46.      xor    dx,dx           ;  DX=0 stands for LPT1
  47. Next:    xor    ah,ah           ;  clear AH (function 0 - print character)
  48.      lodsb                  ;  send current character into AL
  49.      int    17h             ;  BIOS printer service
  50.      test   ah,08h          ;  was there an error?
  51.      jnz    Error           ;  if so - put message and exit
  52.      loop   Next            ;  print next character
  53.      jmp    Exit            ;  exit program (normal exit)
  54. Error:   lea    dx,MSG2         ;  DS:DX - addres of error message
  55. ;----------------------------------------------------------
  56. ;--- Exit the program (normal or error)
  57. Text:    mov    ah,9            ;  function 09h - output text string
  58.      int    21h             ;  DOS service call
  59. Exit:    mov    ax,4C00h        ;  Return Code =0
  60.      int    21h             ;  Return to  MS-DOS
  61.      END
  62.